package design.aopdemo.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Order(2)
@Aspect
public class AopAspect2 {
    @Pointcut("execution(* design.aopdemo.controller.AopController.show(..))")
    public void print(){

    }
    @Before("print()")
    public void before(){
        System.out.println("before2------");
    }
    @After("print()")
    public void after(){
        System.out.println("after2------");
    }
    @AfterReturning("print()")
    public void afterReturning(){
        System.out.println("afterReturning2------");
    }
    @AfterThrowing("print()")
    public void afterThrowing(){
        System.out.println("afterThrowing2------");
    }

    @Around("print()")
    public void around(ProceedingJoinPoint proceedingJoinPoint){
        System.out.println("around before2");
        try {
            proceedingJoinPoint.proceed();
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
        System.out.println("around after2");
    }
}
